home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
BSMSCDEX.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-21
|
4KB
|
171 lines
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: bsmscdex.c
// Title: Base library
// Notice: John M. Weeder
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
//
// This module contains MSCDEX support. This support is only valid under DOS.
//
// The code in this module should be written entirely in C.
// Do not use any C++ constructs.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
// SCO UNIX.
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
// SCO UNIX cc
//
//----------------------------------------------------------------------------
#include <bs.h>
//----------------------------------------------------------------------------
// Description: Return drive id of first CDROM drive
// Parameters: psDrive Variable to return drive id in.
// Drive = 'A', 'B',...
// Returns: TRUE if MSCDEX installed.
//----------------------------------------------------------------------------
BOOL FN_E MscdexFirstDrive(PSHORT psDrive)
{
#if OS_DOS || OS_WINDOWS
USHORT usDriveCnt;
SHORT sDrive;
_asm {
mov ax, 01500h
xor bx, bx
int 2Fh
mov [usDriveCnt], bx
mov [sDrive], cx
}
if (psDrive && usDriveCnt)
psDrive[0] = sDrive + 'A';
return usDriveCnt != 0;
#else
NOTUSED(psDrive);
return FALSE;
#endif // #if OS_DOS
}
//----------------------------------------------------------------------------
// Description: Check if a drive is a CDROM
// Parameters: sDrive Drive to check.
// 1=A, 2=B or 'A', 'B', ...
// Returns: TRUE if valid CDROM drive.
//----------------------------------------------------------------------------
BOOL FN_E MscdexIsCdrom(SHORT sDrive)
{
#if OS_DOS || OS_WINDOWS
USHORT usSignature;
USHORT usResult;
if (sDrive >= 'A' && sDrive <= 'Z')
sDrive = (SHORT)(sDrive - 'A');
if (sDrive >= 'a' && sDrive <= 'z')
sDrive = (SHORT)(sDrive - 'a');
if (sDrive < 0 || sDrive >= 26)
return FALSE;
_asm {
mov ax, 0150Bh
xor bx, bx
mov cx, [sDrive]
int 2Fh
mov [usSignature], bx
mov [usResult], ax
}
return usResult && usSignature == 0xADAD;
#else
NOTUSED(sDrive);
return FALSE;
#endif // #if OS_DOS
}
//----------------------------------------------------------------------------
// Description: Check if MSCDEX is installed
// Parameters:
// Returns: TRUE if MSCDEX installed.
//----------------------------------------------------------------------------
BOOL FN_E MscdexIsInstalled(void)
{
#if OS_DOS || OS_WINDOWS
USHORT usDriveCnt;
_asm {
mov ax, 01500h
xor bx, bx
int 2Fh
mov [usDriveCnt], bx
}
return usDriveCnt != 0;
#else
return FALSE;
#endif // #if OS_DOS
}
//----------------------------------------------------------------------------
// Description: Run standard test suite
// Parameters: sTest Test to run.
// 0 Run all default tests (except).
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
#if COMPILE_TEST
BOOL FN MscdexTest(SHORT sTest)
{
NOTUSED(sTest);
if (MscdexIsInstalled())
{
SHORT sDrive;
Output("MSCDEX is installed.\n");
if (!MscdexFirstDrive(&sDrive))
return FALSE;
Output("First CDROM drive is %c:.\n", sDrive);
for (sDrive = 'A'; sDrive <= 'Z'; ++sDrive)
if (MscdexIsCdrom(sDrive))
Output("Drive %c: is a CDROM.\n", sDrive);
}
else
Output("MSCDEX is not installed.\n");
return TRUE;
}
#endif
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------